// song.cpp

// 2008-04-24 22:00:30 (Jake): created

#include "crankit_precompiled.h"

#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>

#include "game.h"
#include "song.h"
#include "midisongloader.h"

using namespace std;

Song::Song(const std::string& path) : _path(path) 
{

}

void Song::loadInfo()
{
	string file = _path + "song.ini";
}

void Song::loadImages()
{
	string file = _path + "label.png";

}

void Song::loadNotes()
{
	string file = _path + "notes.mid";

	MidiSongLoader songLoader;
	songLoader.load(file);

	_notes = songLoader.getNotes();
	sort(_notes.begin(), _notes.end());

	_tempoList = songLoader.getTempoList();
	_ticksPerBeat = songLoader.getTicksPerBeat();
}

float Song::getBaseBPM()
{
	if (_tempoList.empty()) {
		throw runtime_error("getBaseBMP called when tempoList was empty");
	}

	int tempo = _tempoList[0].tempo;
	float bpm = 60 * 1.0e6 / tempo;
	
	return bpm;
}

string Song::getSongFile() const
{
	return _path + "song.ogg";
}

string Song::getGuitarFile() const
{
	return _path + "guitar.ogg";
}

void Song::loadMusic()
{

}
